package pub.gll.plugin.util;


import java.util.List;

import pub.gll.plugin.asm.model.Source;
import pub.gll.plugin.asm.model.Target;

public class CallInfoUtils {
    /**
     * 判断是否在白名单中
     * @param target 目标插入描述
     * @param source 源插入描述
     * @return
     */
    public static boolean isInRunMethodInstWhiteList(Target target, Source source) {
        if (target == null) {
            return false;
        }
        List<String> callerInfoList = target.getCallerInfoList();
        if (callerInfoList == null || callerInfoList.isEmpty()) {
            return true;
        }
        for (String callerInfo : callerInfoList) {
            if (StringUtil.isEmpty(callerInfo)) {
                continue;
            }
            if (source != null && source.getClassName().matches(callerInfo)) {
                return true;
            }
        }
        return false;
    }
}
